﻿<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="BusinessView.aspx.cs"
    Inherits="FeedbackWebClient.BusinessView" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="css/site.css" rel="stylesheet" type="text/css" />
    <link href="css/jquery.alerts.css" rel="stylesheet" type="text/css" />

    <script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
    <script src="js/plugin/jquery.alerts.min.js" type="text/javascript"></script>    
</head>
<body>
    <form id="form1" runat="server">
    <div class="main">
        <fieldset>
            <p>
                <span class="inputLabel">Store Name</span>
                <asp:TextBox runat="server" ID="StoreName" CssClass="textInput" MaxLength="128"></asp:TextBox>
                <asp:RequiredFieldValidator ID="StoreNameRequired" runat="server" ControlToValidate="StoreName"
                    CssClass="failureNotification" ErrorMessage="Store name is required." Text="*"
                    SetFocusOnError="true" ToolTip="Store name is required." ValidationGroup="BusinessValidationGroup"></asp:RequiredFieldValidator>
            </p>
            <p>
                <span class="inputLabel">First Name</span>
                <asp:TextBox runat="server" ID="FirstName" CssClass="textInput" MaxLength="128"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFirstName" runat="server" ControlToValidate="FirstName"
                    CssClass="failureNotification" ErrorMessage="First name is required." Text="*"
                    SetFocusOnError="true" ToolTip="First name is required." ValidationGroup="BusinessValidationGroup"></asp:RequiredFieldValidator>
            </p>
            <p>
                <span class="inputLabel">Last Name</span>
                <asp:TextBox runat="server" ID="LastName" CssClass="textInput" MaxLength="128"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredLastName" runat="server" ControlToValidate="LastName"
                    CssClass="failureNotification" ErrorMessage="Last name is required." Text="*"
                    SetFocusOnError="true" ToolTip="Last name is required." ValidationGroup="BusinessValidationGroup"></asp:RequiredFieldValidator>
            </p>
            <p>
                <span class="inputLabel" maxlength="128">Email</span>
                <asp:TextBox runat="server" ID="Email" CssClass="textInput"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredEmail" runat="server" ControlToValidate="Email"
                    CssClass="failureNotification" ErrorMessage="Email is required." Text="*" SetFocusOnError="true"
                    ToolTip="Email is required." ValidationGroup="BusinessValidationGroup"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator runat="server" ID="revEmail" ControlToValidate="Email"
                    ErrorMessage="Enter a valid email address." ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                    SetFocusOnError="true" Text="*" ValidationGroup="BusinessValidationGroup" ToolTip="Enter a valid email address."
                    CssClass="failureNotification" />
            </p>
            <p>
                <span class="inputLabel">Password</span>
                <asp:TextBox runat="server" ID="Password" TextMode="Password" CssClass="textInput"
                    MaxLength="128"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredPassword" runat="server" ControlToValidate="Password"
                    CssClass="failureNotification" ErrorMessage="Password is required." Text="*"
                    SetFocusOnError="true" ToolTip="Password is required." ValidationGroup="BusinessValidationGroup"></asp:RequiredFieldValidator>
            </p>
            <p>
                <span class="inputLabel">Business Mail</span>
                <asp:TextBox runat="server" ID="BusinessMail" CssClass="textInput" MaxLength="128"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredBusinessMail" runat="server" ControlToValidate="BusinessMail"
                    CssClass="failureNotification" ErrorMessage="Business Mail is required." Text="*"
                    SetFocusOnError="true" ToolTip="Business Mail is required." ValidationGroup="BusinessValidationGroup"></asp:RequiredFieldValidator>
                <span id="feedbreakMail">@feedbreak.com</span> <a href="#" id="lnkmailAvailable">Check
                    mail is available</a>
            </p>
            <p>
                <asp:Button runat="server" ID="btnSave" OnClick="btnSave_Click" CssClass="button businessSave"
                    ValidationGroup="BusinessValidationGroup" Text="Save" />
            </p>
        </fieldset>
        <script type="text/javascript">
            $(document).ready(function () {
                $("#lnkmailAvailable").click(function () {
                    var nameBox = $('#<%= BusinessMail.ClientID %>')[0];
                    CheckBusinessEmailValidity(nameBox.value, nameBox);
                });
            });
            function CheckBusinessEmailValidity(name, nameBox) {
                $.ajax({
                    type: "POST",
                    url: "BusinessView.aspx/IsBusinessEmailAddressExist",
                    data: "{value:'" + name + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) {
                        if (msg.d == true) {
                            nameBox.value = '';
                            jAlert("This email address already exists. Please try another email address", "Invalid email address");
                        }
                        else {
                            jAlert("This email address is available.", "Valid email address");
                        }
                    }
                });
            }
        </script>
    </div>
    </form>
</body>
</html>
